CFLAGS = -Wall -pedantic -ansi

ALL := argument beer param_test
sources := $(wildcard *.c) 

#all
all: $(ALL)
.PHONY: all

# rules
argument: argument.o does_not.o does_too.o error.o
	gcc $(CFLAGs) -o $@ $^ -lpthread
beer: beer.o drink_lots.o error.o
	gcc $(CFLAGS) -o $@ $^ -lpthread
param_test: param_test.o do_stuff.o error.o
	gcc $(CFLAGS) -o $@ $^ -lpthread

#.d generation
%.d: %.c
	@set -e; rm -f $@; \
	gcc -MM $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ >$@; \
	rm -f $@.$$$$

# include all the .d files
include $(sources:.c=.d)

# clean action
.PHONY: clean cleanAll cleanBin cleanObj cleanDep
clean: cleanDep cleanObj

cleanAll: clean cleanBin

cleanDep:
	-rm *.d

cleanObj:
	-rm *.o

cleanBin:
	-rm $(ALL)
# add something to test 
